public class FindTheNumerousNums {
    public static int solution(int[] array){
        int count=0;
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array.length; j++) {
                if(array[i]==array[j]){
                    count++;
                }
            }
            if(count>array.length/2){
                return array[i];
            }
            count=0;
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] nums={1,1,2,2,2};
        System.out.println(solution(nums));
    }
}
